home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
CC_C
/
0151.ZIP
/
EXPAND.C
< prev
next >
Wrap
Text File
|
1982-12-30
|
1KB
|
59 lines
#include <stdio.h>
#include <ctype.h>
/************************************************
* *
* -- E X P A N D -- *
* *
* Expand command line args into *
* a file. *
* *
* T. Jennings 30 Dec. 82 *
* created 22 Nov. 82 *
* *
* *
************************************************/
main(argc,argv)
int argc;
char *argv[];
{
long size;
long fsize;
int i;
char file[80];
FILE *fi;
char filespec[80];
char thing[80];
char secondthing[80];
char name[80];
if (argc < 4) {
printf("EXPAND <file> <thing> <filespec> <2ndthing> creates <file> which\n");
printf(" contains a copy of <thing> and one match from\n");
printf(" <filespec>, followed by <2ndthing>, if it exists.\n");
exit(1);
}
strcpy(file,argv[1]);
strcpy(thing,argv[2]);
strcpy(filespec,argv[3]);
strcpy(secondthing,"");
if (argc > 4)
strcpy(secondthing,argv[4]);
i= 0;
fi= fopen(file,"w");
if (fi == 0) {
printf("Can't create %s\n",file);
exit(1);
}
while (xfind(filespec,name,&fsize,0,i)) {
fprintf(fi,"%s %s %s\n",thing,name,secondthing);
++i;
}
printf("Made %d lines.\n",i);
fclose(fi);
exit(0);
}